package com.medisched.medisched.controller;

import com.medisched.medisched.domain.Department;
import com.medisched.medisched.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 科室Controller
 * 
 * @author ruoyi
 * @date 2025-05-15
 */
@CrossOrigin
@RestController
@RequestMapping("/system/department")
public class DepartmentController
{
    @Autowired
    private IDepartmentService departmentService;

    /**
     * 查询科室列表
     */
    @GetMapping("/list")
    public List<Department> list(Department department)
    {
        return departmentService.selectDepartmentList(department);
    }

    /**
     * 获取科室详细信息
     */
    @GetMapping(value = "/{id}")
    public Department getInfo(@PathVariable("id") Long id)
    {
        return departmentService.selectDepartmentById(id);
    }

    /**
     * 新增科室
     */
    @PostMapping
    public int add(@RequestBody Department department)
    {
        return departmentService.insertDepartment(department);
    }

    /**
     * 修改科室
     */
    @PutMapping
    public int edit(@RequestBody Department department)
    {
        return departmentService.updateDepartment(department);
    }

    /**
     * 删除科室
     */
	@DeleteMapping("/{ids}")
    public int remove(@PathVariable Long[] ids)
    {
        return departmentService.deleteDepartmentByIds(ids);
    }
}
